package process_contr;

import org.junit.Test;

import java.util.Scanner;

public class Demo1 {
    @Test
    public void test4() {
        // 求100以内的所有质数并打印质数：素数，只能被1和它本身整除的自然数，最小的质数是：2
        for (int i = 2; i < 100; i++) {
            boolean flag = true; // 默认是质数
            for (int j = 2; j < i; j++) {
                if (i % j == 0) {
                    // 非质数
                    flag = false;
                    break;
                }
            }
            if (flag) {
                System.out.println(i + "是质数");
            } else {
                // System.out.println(i + "不是质数");
            }
        }


    }

    @Test
    public void test3() {
        // 求n的阶乘 9 * 8 * 7 * ... * 1
        int result = 1;
        for (int i = 9; i > 0; i--) {
            result *= i;
        }
        System.out.println(result);
    }

    @Test
    public void test2() {
        for (int i = 1; i <= 150; i++) {
            if (i % 3 == 0) {
                System.out.println(i + " foo");
            } else if (i % 5 == 0) {
                System.out.println(i + " biz");
            } else if (i % 7 == 0) {
                System.out.println(i + " baz");
            } else {
                System.out.println(i);
            }
        }

    }


    @Test
    public void test1() {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        if (num <= 2) {
            System.out.println(num * 10.5);
        } else {
            System.out.println(2 * 10.5 + (num - 2) * 4);
        }

    }
}
